<template>
  <div class="wrap headerwrap">
    <!-- logo -->
    <div class="logo">
      <img src="@/assets/img/indexLogo.6f8ac4f0.png" />
    </div>
    <!-- 导航 -->
    <ul class="navs">
      <li
        :class="{ active: $route.path == '/home' }"
        @click="$router.push('/home')"
      >
        首页
      </li>
      <li
        :class="{ active: $route.path == '/goods' }"
        @click="$router.push('/goods')"
      >
        全部商品
      </li>
      <li
        :class="{ active: $route.path == '/user' }"
        @click="$router.push('/user')"
      >
        个人中心
      </li>
      <li
        :class="{ active: $route.path == '/order' }"
        @click="$router.push('/order')"
      >
        我的订单
      </li>
      <li
        :class="{ active: $route.path == '/free' }"
        @click="$router.push('/free')"
      >
        专属福利
      </li>
    </ul>
    <!-- 搜索 -->
    <div class="search">
      <input type="text" placeholder="请输入关键字" v-model="searchKeyword" />
      <span @click="searchKeywordFn">
        <img src="@/assets/img/search.png" alt="" />
      </span>
    </div>
  </div>
</template>

<script>
/* 
  1.配置路由·(path, component)
  2.header. vue·通过编程式路由实现页面跳转
  3.实现高亮
    通过当前路由对象的路径进行判断$route.path
*/
export default {
  data() {
    return {
      searchKeyword: "",
    };
  },
  methods: {
    searchKeywordFn() {
      this.$router.push(`/goods?keyword=${this.searchKeyword}`);
      this.searchKeyword = "";
    },
  },
};
</script>

<style lang="less" scoped>
.headerwrap {
  height: 118px;
  display: flex;
  justify-content: space-between;
  align-items: center;

  .navs {
    width: 500px;
    display: flex;
    justify-content: space-between;
    li {
      cursor: pointer;
    }
    .active {
      font-size: 16px;
      font-weight: 500;
      color: #0a328e;
    }
  }
  .search {
    display: flex;
    cursor: pointer;
    input {
      width: 214px;
      height: 40px;
      border: 1px solid #dedede;
      border-radius: 20px 0px 0px 20px;
      box-sizing: border-box;
      outline: none;
      text-indent: 1em;
    }
    span {
      width: 50px;
      height: 40px;
      background: #0a328e;
      border-radius: 0px 20px 20px 0px;
      line-height: 40px;
      text-align: center;
    }
  }
}
</style>